<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [1,3,3,3,1,5,6,7,8,1]

        function unique(arr){
            if(!Array.isArray(arr)){
                console.log('type error!');
                return
            }
            var array = []
            for(var i = 0; i < arr.length; i++){
                if(array.indexOf(arr[i] < 0)){
                    array.push(arr[i])
                }
            }
            return array
        }
        unique(arr)
        console.log(arr);
        

    </script>
</body>

</html>